<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 
        <title>Welcome to Design Zone......</title>
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/ext-all.css" />
        <link rel="stylesheet" type="text/css" href="../../styles/dzbase.css" />
        <script type="text/javascript" src="../../scripts/ext/adapter/ext-base.js">
        </script>
        <script type="text/javascript" src="../../scripts/ext/ext-all.js">
        </script>
        <script type="text/javascript" src="../../scripts/menu/EditableItem.js">
        </script>
        <script type="text/javascript" src="../../scripts/menu/RangeMenu.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/GridFilters.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/Filter.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/StringFilter.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/ListFilter.js">
        </script>
		<script type="text/javascript" src="../../scripts/grid/filter/DateFilter.js"></script>
		<script type="text/javascript" src="../../scripts/grid/RowExpander.js">
        </script>
        <script type="text/javascript" src="../../scripts/i18nMessage.js">
        </script>
        <script type="text/javascript" src="../../scripts/utils.js">
        </script>
        <script type="text/javascript">
        	var piMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.productidentification');
			var referenceMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.reference');
			var colorMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.pantonecolor');
			var fcMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.francecustomer');
			var fMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.factory');
            var message = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=message');
			
			var ctCollarTypeXmlLoader = new i18nMessage('../../servlet/CodeTableServlet?name=CtCollarType');
			var ctSeasonNumberXmlLoader = new i18nMessage('../../servlet/CodeTableServlet?name=CtSeasonNumber');
			var ctVersionXmlLoader = new i18nMessage('../../servlet/CodeTableServlet?name=CtVersion');
			var ctProductFamilyXmlLoader = new i18nMessage('../../servlet/CodeTableServlet?name=CtProductFamily');
			var ctDesignTypeXmlLoader = new i18nMessage('../../servlet/CodeTableServlet?name=CtDesignType');
			
			var store;
            var grid;
			
			var deleteCallback = function(btn){
                if (btn == 'yes') {
                    Ext.Ajax.request({
                        url: '../../servlet/ProductIdentificationServlet?action=2&id=' + deleteId,
                        success: function(o){
                            if (o.responseText == 'success') {
                                store.reload();
                                messageTip.msg(message.get('message.tip'), message.get('message.delete.successful'));
                            }
                            else {
                                messageTip.msg(message.get('message.tip'), message.get('message.delete.unsuccessful'));
                            }
                        },
                        failure: function(o){
                            messageTip.msg(message.get('message.tip'), message.get('message.delete.failure'));
                        },
                        params: {
                            foo: 'bar'
                        }
                    });
                }
            }
			
			Ext.onReady(function(){
                // create the Data Store
                
                
                store = new Ext.data.Store({
                    // load using HTTP
                    url: '../../servlet/ProductIdentificationServlet?action=100',
                    
                    // the return will be XML, so lets set up a reader
                    reader: new Ext.data.XmlReader({
                        // records will have an "Item" tag
                        record: 'item',
                        id: 'id',
                        totalRecords: 'itemTotal'
                    }, [ 
					 'index', 'id', 'ctProductFamily', 'biMeasureSpecificationId',
					 'ctMachineType', 'type', 'orderNumber',
					 'yarnNumber', 'dhlNumber', 'ctDesignType',
					 'style', 'customerLinkman', 'model', 
					 'ctSeasonNumber', 'createDate', 'reference',
					 'ctVersion', 'patronageNumer', 'front', 
					 'back', 'sleeves', 'bottomThrum', 
					 'sleevesThrum', 'necklineThrum', 'needle', 
					 'weight', 'comment', 'photoName', 'frontPhotoName','backPhotoName','otherPhotoName',
					 'chartName', 'modifyDate', 
					 'isSimilary', 'isNewfashioned', 'isDifficulty', 
					 'dhlNumber', {name: 'biFranceCustomer.name', mapping: 'customerName'},
					 {name: 'biFranceCustomer.department', mapping: 'customerDepartment'},'isTagged','isYarned', 'isOrdered', 'isButtoned', 'isZipped', 'isAo']),
                    
                    remoteSort: true
                });
			
				store.setDefaultSort('id', 'desc');
				
				var filters = new Ext.grid.GridFilters({
					  filters:[
						{type: 'string',  dataIndex: 'biFranceCustomer.name'},
						{type: 'string',  dataIndex: 'biFranceCustomer.department'},
						{type: 'string',  dataIndex: 'model'},
						{type: 'string',  dataIndex: 'reference'},
						{type: 'string',  dataIndex: 'style'},
						{type: 'date',  dataIndex: 'createDate'},
						{type: 'date',  dataIndex: 'modifyDate'},
						{type: 'list',  dataIndex: 'ctSeasonNumber', options: ctSeasonNumberXmlLoader.getCtArray() },
						{type: 'list',  dataIndex: 'ctProductFamily', options: ctProductFamilyXmlLoader.getCtArray() },
						{type: 'list',  dataIndex: 'ctDesignType', options: ctDesignTypeXmlLoader.getCtArray() },
						{type: 'list',  dataIndex: 'ctVersion',options: ctVersionXmlLoader.getCtArray()},
						{type: 'string',  dataIndex: 'patronageNumer'}
				]});
				
				var expander = new Ext.grid.RowExpander({
			        tpl : new Ext.Template(
						'<p><b>' + piMessage.get('ui.productidentification.style') + ':</b> {style}</p><br/> ',
						'<p><b>' + piMessage.get('ui.productidentification.ordernumber') + ':</b> {orderNumber} &nbsp;&nbsp;&nbsp;&nbsp;<b>' + piMessage.get('ui.productidentification.dhl') + ':</b> {dhlNumber} &nbsp;&nbsp;&nbsp;&nbsp;</p><br/>',
			            '<p><b>' + referenceMessage.get('ui.reference.front') + ':</b> {front} &nbsp;&nbsp;&nbsp;&nbsp; <b>' + referenceMessage.get('ui.reference.back') + ':</b> {back}&nbsp;&nbsp;&nbsp;&nbsp;',
						'<b>' + referenceMessage.get('ui.reference.sleeves') + ':</b> {sleeves} &nbsp;&nbsp;&nbsp;&nbsp; <b>' + referenceMessage.get('ui.reference.bottomthrum') + ':</b> {bottomThrum}&nbsp;&nbsp;&nbsp;&nbsp;',
						'<b>' + referenceMessage.get('ui.reference.sleevesthrum') + ':</b> {sleevesThrum} &nbsp;&nbsp;&nbsp;&nbsp; <b>' + referenceMessage.get('ui.reference.necklinethrum') + ':</b> {necklineThrum}&nbsp;&nbsp;&nbsp;&nbsp;</p><br/>',
			            '<p><b>' + referenceMessage.get('ui.reference.needle') + ':</b> {needle} &nbsp;&nbsp;&nbsp;&nbsp; <b>' + referenceMessage.get('ui.reference.machinetype') + ':</b> {ctMachineType}&nbsp;&nbsp;&nbsp;&nbsp;',
						'<b>' + referenceMessage.get('ui.reference.weight') + ':</b> {weight} &nbsp;&nbsp;&nbsp;&nbsp; <b>',// + piMessage.get('ui.productidentification.yarnnumber') + ':</b> {yarnNumber}&nbsp;&nbsp;&nbsp;&nbsp;',
						'</p><br/>',
						'<p><img src="../../_temp/{chartName}" width="150px"/> &nbsp;&nbsp;&nbsp;&nbsp;<img src="../../_temp/{photoName}" width="150px"/>',
						//&nbsp;&nbsp;&nbsp;&nbsp;<img src="../../_temp/{frontPhotoName}" width="150px"/>&nbsp;&nbsp;&nbsp;&nbsp;<img src="../../_temp/{backPhotoName}" width="150px"/>&nbsp;&nbsp;&nbsp;&nbsp;<img src="../../_temp/{otherPhotoName}" width="150px"/></p><br/>',
						'<br/><br/><p><b>' + piMessage.get('ui.productidentification.comment') + ':</b> {comment}</p><br/>'
			        )
			    });
				
				grid = new Ext.grid.GridPanel({
                    title: piMessage.get('ui.productidentification.listtitle'),
                    store: store,
					stripeRows: true,
					plugins: [filters, expander],
                    height: 560,
                    columns: [expander, {
                        header: message.get('message.list.id'),
                        width: 50,
                        dataIndex: 'index',
                        sortable: false
                    }, {
                        header: fcMessage.get('ui.francecustomer.name'),
                        dataIndex: 'biFranceCustomer.name',
                        sortable: true
                    }, {
                        header: fcMessage.get('ui.francecustomer.department'),
                        dataIndex: 'biFranceCustomer.department',
                        sortable: true
                    },{
                        header: piMessage.get('ui.productidentification.style'),
                        dataIndex: 'style',
                        sortable: true
                    },{
                        header: message.get('message.edit.productfamily'),
                        dataIndex: 'ctProductFamily',
                        sortable: true
                    },{
                        header: piMessage.get('ui.productidentification.designtype'),
                        dataIndex: 'ctDesignType',
                        sortable: true
                    },{
                        header: referenceMessage.get('ui.reference.reference'),
                        dataIndex: 'reference',
                        sortable: true
                    },{
                        header: piMessage.get('ui.productidentification.seasonnumber'),
                        dataIndex: 'ctSeasonNumber',
                        sortable: true
                    },{
                        header: piMessage.get('ui.productidentification.model'),
                        dataIndex: 'model',
                        sortable: true
                    },{
                        header: piMessage.get('ui.productidentification.chartversion'),
                        dataIndex: 'ctVersion',
                        sortable: true
                    },{
                        header: piMessage.get('ui.productidentification.patronagenumer'),
                        dataIndex: 'patronageNumer',
                        sortable: true
                    },{
                        header: message.get('message.edit.createdate'),
                        dataIndex: 'createDate',
                        sortable: true
                    },{
                        header: message.get('message.edit.modifydate'),
                        dataIndex: 'modifyDate',
                        sortable: true
                    },{
                        header: piMessage.get('ui.productidentification.addtimeline'),
                        width: 80,
                        dataIndex: 'id',
                        sortable: false,
                        renderer: renderEdit
                    }],
                    viewConfig: {
                        forceFit: true
                    },
                    loadMask: true,
                    renderTo: 'productIdentificationGrid',
                    bbar: new Ext.PagingToolbar({
                        pageSize: 20,
                        store: store,
                        displayInfo: true
                    })
                });
                
                var startPage = getPrarmeterValue(window.location, 'startPage');
                var start;
                if (startPage == null || startPage == '') {
                    start = 0;
                }
                else {
                    start = (startPage - 1) * 20;
                }
                store.load({
                    params: {
                        start: start,
                        limit: 20
                    }
                });
				
				function renderEdit(value, p, record){
                    return String.format('<a href="product_time_line_edit.html?id={0}&startPage={1}" target="_self"><img src="../../images/icons/time_add.png" title="' + piMessage.get('ui.productidentification.addtimeline') + '" /></a>', record.id, Math.floor((record.data.index - 1) / 20) + 1);
                }

			});
        
        </script>
    </head>
    <body>
    		<div id="productIdentificationGrid"></div>
    </body>
</html>
